package com.zym.controller.common.file;

import com.zym.config.ProProperties;
import com.zym.enums.AckCode;
import com.zym.service.FileUpload2Service;
import com.zym.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.util.UUID;

/*
分片文件文件，适合大文件的上传

 */
@Api(tags = "文件操作")
@RestController
@RequestMapping("/file2")
public class FileUpload2 {
    private static final Logger log = LoggerFactory.getLogger(FileUpload1.class);

    @Autowired
    private FileUpload2Service fileUpload2Service;
    @ApiOperation("对文件切分")
    @PostMapping("/split")
    public R fileUpload(@RequestParam("file") MultipartFile file, HttpServletRequest request){

        Boolean b=fileUpload2Service.fileUpload2(file);
        return  b ? R.ok():R.build(AckCode.FAIL);

    }
    @ApiOperation("对文件合并")
    @PostMapping("/merge")
    public R fileUpload(){

        Boolean b=fileUpload2Service.fileMerge();
        return  b ? R.ok():R.build(AckCode.FAIL);

    }
}
